package cn.uce.cc.rest.control;

import cn.uce.base.page.Pagination;
import cn.uce.base.page.Page;
import cn.uce.cc.api.service.biz.ICcWoCustSerBiz;
import cn.uce.common.constants.CcConstants;
import cn.uce.ics.base.entity.cs.CsWoCustSer;
import cn.uce.ics.base.entity.cs.CsWoWorkOrder;
import cn.uce.ics.base.vo.cs.CsWoCustSerVo;
import cn.uce.web.common.base.BaseController;
import cn.uce.web.common.util.WebUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * cc来电弹屏关于客服工单的controller
 */
@Controller
@RequestMapping("/cs/CsWoCustSer")
public class CcWoCustSerController extends BaseController {


    @Resource
    private ICcWoCustSerBiz ccWoCustSerBiz;

    /**
     * 客服服务工单提交
     * **/
    @RequestMapping(value = "/submit")
    @ResponseBody
    public Map<String, Object> submit(CsWoCustSer csWoCustSer, CsWoWorkOrder csWoWorkOrder){

        return this.returnSuccess(ccWoCustSerBiz.submit(csWoCustSer,csWoWorkOrder,WebUtil.getCurrentUser()));
    }

    /**
     * 来电弹屏受理中和已完结工单查询列表--非分页非限制显示条数
     * @param csWoCustSerVo
     * */
    @RequestMapping("/getCsWoCustSerVoList")
    @ResponseBody
    public Map<String,Object> getCsWoCustSerVoList(CsWoCustSerVo csWoCustSerVo, Page page){
        //工单种类0:客服服务类工单
        csWoCustSerVo.setWoKind(CcConstants.DICT_KIND_CUST_SER);
        //来源：0 400来电
        //csWoCustSerVo.setSource(CcConstants.DICT_SOURCE_CUST_SER);

        return (Map<String, Object>) ccWoCustSerBiz.getCsWoCustSerVoLists(csWoCustSerVo,page);
    }


    /**
     *获取流程首节点处理信息
     * **/
    @RequestMapping(value = "/getFirstNodeDealOrg")
    @ResponseBody
    public Map<String, Object> getFirstNodeDealOrg(String wayBillNum,Long orderChilType,int source){
        Map<String, Object> map =ccWoCustSerBiz.getFirstNodeDealOrg(wayBillNum,orderChilType,source);
        return  this.returnSuccess(map);
    }


    /**
     *
     *工单创建规则校验，呼叫中心工单：同一个来电号码，同一个运单，同一个类型，不可创建同类工单
     * 0；不存在1：存在
     * **/
    @RequestMapping(value = "/checkSameCsWoCustSer")
    @ResponseBody
    public Map<String, Object> checkSameCsWoCustSer(CsWoCustSerVo csWoCustSerVo){
        int res =ccWoCustSerBiz.checkSameCsWoCustSer(csWoCustSerVo);
        return  this.returnSuccess(res);
    }

    /**
     * 判断是否可以创建
     * 0允许 1：无签收扫描不允许 2：无签收扫描/无派件不允许
     * **/
    @RequestMapping(value = "/checkCanCreate")
    @ResponseBody
    public Map<String, Object> checkCanCreate(String wayBillNum,Long orderChilType,int source){
        int res =ccWoCustSerBiz.checkCanCreate(wayBillNum,orderChilType,source);
        return  this.returnSuccess(res);
    }

    /**
     * 判断运单号必填
     * 工单类型，工单子类型是否有对应400流程
     * **/
    @RequestMapping(value = "/checkRequireWayBillNum")
    @ResponseBody
    public Map<String, Object> checkRequireWayBillNum(Long orderType, Long orderChilType,int source){
        int res =ccWoCustSerBiz.checkRequireWayBillNum(orderType,orderChilType,source);
        return  this.returnSuccess(res);
    }

    /**
     * 判断提交时是否手动选择第一节点处理人
     * 返回手动选择类型0:不手动选择3:中心或网点 11：网点12：中心
     * **/
    @RequestMapping(value = "/checkManualSelMechanism")
    @ResponseBody
    public Map<String, Object> checkManualSelMechanism(Long orderChilType,int source){
        int res =ccWoCustSerBiz.checkManualSelMechanism(orderChilType,source);
        return  this.returnSuccess(res);
    }

}
